<template>
  <div class="header">
    <div class="main">
      <div class="logo">
        <nuxt-link to="/">
          <img src="@/assets/logo1.png" alt />
        </nuxt-link>
      </div>
      <div class="navs">
        <nuxt-link to="/">首页</nuxt-link>
        <nuxt-link to="/raider">旅游攻略</nuxt-link>
        <nuxt-link to="/hotel">酒店</nuxt-link>
        <nuxt-link to="/air">国内机票</nuxt-link>
      </div>
      <div class="login">
        <el-dropdown v-if="$store.state.user.userInfo.token">
          <el-row type="flex" align="middle" class="el-dropdown-link">
            <img :src="$axios.defaults.baseURL + $store.state.user.userInfo.user.defaultAvatar" />
            {{$store.state.user.userInfo.user.nickname}}
            <i
              class="el-icon-caret-bottom el-icon--right"
            ></i>
          </el-row>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item>
              <!-- <nuxt-link to="javascript:;">个人中心</nuxt-link> -->
              <div>个人中心</div>
            </el-dropdown-item>
            <el-dropdown-item>
              <div @click="logout">退出</div>
            </el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
        <nuxt-link v-else to="/user/login">登录/注册</nuxt-link>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  methods: {
    logout() {
      this.$store.commit("user/setUserInfo", {});
    }
  }
};
</script>

<style lang="less" scoped>
.header {
  width: 100%;
  height: 60px;
  line-height: 60px;
  .main {
    display: flex;
    justify-content: space-between;
    width: 1000px;
    height: 100%;
    margin: 0 auto;
    .logo {
      width: 150px;
      padding-top: 11px;
      img {
        width: 150px;
      }
    }
    .navs {
      flex: 1;
      display: flex;
      .nuxt-link-exact-active {
        background: #409eff;
        color: #fff !important;
      }
      a {
        display: block;
        padding: 0 20px;
        height: 60px;
        box-sizing: border-box;
        &:hover {
          border-bottom: 5px solid #409eff;
        }
      }
    }
    .login {
      font-size: 14px;
      .el-dropdown-link {
        cursor: pointer;
        &:hover {
          img {
            border-color: #409eff;
          }
        }
      }
      img {
        width: 32px;
        height: 32px;
        vertical-align: middle;
        border: 2px #fff solid;
        border-radius: 50%;
        margin-right: 5px;
      }
    }
  }
}
.header .navs .nuxt-link-active:not(:first-child),
.header .navs .nuxt-link-exact-active {
  background: #409eff;
  color: #fff !important;
}
</style>